<table width="100%" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed; background: #FFFFFF; padding-left:10px; padding-right:10px;">
	<tr>
		<td colspan="3">
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td align="right" class="admin_cell" valign="top" style="padding-right:10px;">
						<?php
							if($temp_rows)
							{
								foreach($temp_rows as $tr)
								{
									
									echo '<table style="padding-bottom:10px;" height="160" width="100%" cellpadding="0" cellspacing="0" border="0" class="template_row">';
									echo '<tr>';
									echo '<td>';
									?>
									<a href="?item=<?php echo $item['id']; ?>&up=<?php echo $tr; ?>"><img src="../images/system/arrow_up20.png" border="0" /></a><br />
									<a href="?item=<?php echo $item['id']; ?>&down=<?php echo $tr; ?>"><img src="../images/system/arrow_down20.png" border="0" /></a>
									<?php 
									echo '</td>';
									echo '</tr>';
									echo '</table>';
								}
							}
						?>
					</td>
					<td class="admin_cell" colspan="2" style="padding-right:10px;">
						<?php
							if($content)
							{
								foreach($content as $tr)
								{
									
									echo '<table style="padding-bottom:10px;" height="160" width="100%" cellpadding="0" cellspacing="0" border="0" class="template_row">';
									echo '<tr>';
									$j=0;
									foreach($tr as $cell)
									{
										if ($j > 0)
										{ echo '<td width="200" style="padding-left:10px;">'; }
										else
										{ echo '<td width="200">'; }
										echo getBorderHTML(3, 'top');
										?>
										<form action="" name="cell_form<?php echo $cell['id']; ?>" id="cell_form<?php echo $cell['id']; ?>" method="post">
										<table width="100%" cellpadding="0" cellspacing="0" border="0">
											<tr>
												<td class="admin_cell" width="100">Content type:</td>
												<td height="100%"  align="right" style="padding-right:6px;">
													<select name="content_type"  style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&type='+this.value">
														<option value="0" <?php if ($cell['type'] == 0){echo 'selected'; }?>>No Content</option>
														<option value="1" <?php if ($cell['type'] == 1){echo 'selected'; }?>>Module</option>
														<option value="2" <?php if ($cell['type'] == 2){echo 'selected'; }?>>Uploaded Image</option>
														<option value="3" <?php if ($cell['type'] == 3){echo 'selected'; }?>>Html</option>
													</select>
												</td>
											</tr>
											<?php if ($cell['type'] == 1):?>
											<tr>
												<td class="admin_cell" width="100">Module type:</td>
												<td height="100%" align="right" style="padding-right:6px;">
													<select name="content_id" style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&content_cat='+this.value">
														<option value="" selected >Any Type</option>
														<option value="0" <?php if ($cell['content_cat'] == "0"){echo 'selected'; }?>>Regular</option>
														<option value="1" <?php if ($cell['content_cat'] == "1"){echo 'selected'; }?>>List</option>
														<option value="2" <?php if ($cell['content_cat'] == "2"){echo 'selected'; }?>>Block</option>
													</select>
												</td>
											</tr>
											<tr>
												<td class="admin_cell" width="100">Module:</td>
												<td height="100%" align="right" style="padding-right:6px;">
													<select name="content_id" style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&content_id='+this.value">
														<option value="0" selected >None</option>
														<?php 
															$and_str = "";
															if($cell['content_cat'] != "")
															{ $and_str = ' AND type='.$cell['content_cat']; }
															
															$result = mysql_query('SELECT * FROM '.DB_PERFIX.'modules WHERE active=1 '.$and_str.';');
															while($row = mysql_fetch_array($result))
															{
																if ($row['id'] == $cell['content_id'])
																{
																	echo '<option value="'.$row['id'].'" selected>'.$row['name_l'].' '.$row['name_r'].'</option>';
																}
																else
																{
																	echo '<option value="'.$row['id'].'">'.$row['name_l'].' '.$row['name_r'].'</option>';
																}
															}
														?>
													</select>
												</td>
											</tr>
											<?php endif;?>
											<?php if ($cell['type'] == 2):?>
											<tr>
												<td class="admin_cell" width="100">Image type:</td>
												<td height="100%" align="right" style="padding-right:6px;">
													<select name="content_id" style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&content_cat='+this.value">
														<option value="" selected >Any Type</option>
														<option value="0" <?php if ($cell['content_cat'] == "0"){echo 'selected'; }?>>Plain</option>
														<option value="1" <?php if ($cell['content_cat'] == "1"){echo 'selected'; }?>>Local URL</option>
														<option value="2" <?php if ($cell['content_cat'] == "2"){echo 'selected'; }?>>Remote URL</option>
													</select>
												</td>
											</tr>
											<tr>
												<td class="admin_cell" width="100">Image:</td>
												<td height="100%" align="right" style="padding-right:6px;">
													<select name="content_id" style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&content_id='+this.value">
														<option value="0" selected >None</option>
														<?php 
															$and_str = "";
															if($cell['content_cat'] != "")
															{ $and_str = ' AND type='.$cell['content_cat']; }
															
															$result = mysql_query('SELECT * FROM '.DB_PERFIX.'template_images WHERE active=1 '.$and_str.';');
															while($row = mysql_fetch_array($result))
															{
																if ($row['id'] == $cell['content_id'])
																{
																	echo '<option value="'.$row['id'].'" selected>'.$row['name'].'</option>';
																}
																else
																{
																	echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
																}
															}
														?>
													</select>
												</td>
											</tr>
											<?php endif;?>
											<?php if ($cell['type'] == 3):?>
											<tr>
												<td class="admin_cell" width="100">Content:</td>
												<td height="100%" align="right" style="padding-right:6px;">
													<select name="content_id" style="width:80%;" onChange="document.location.href='?item=<?php echo $item['id']; ?>&cell=<?php echo $cell['id']; ?>&content_id='+this.value">
														<option value="0" selected >None</option>
														<?php 
															$result = mysql_query('SELECT * FROM '.DB_PERFIX.'template_html;');
															while($row = mysql_fetch_array($result))
															{
																if ($row['id'] == $cell['content_id'])
																{
																	echo '<option value="'.$row['id'].'" selected>'.$row['name_l'].' '.$row['name_r'].'</option>';
																}
																else
																{
																	echo '<option value="'.$row['id'].'">'.$row['name_l'].' '.$row['name_r'].'</option>';
																}
															}
														?>
													</select>
												</td>
											</tr>
											<?php endif;?>
											<tr>
												<td align="left"  style="padding-left:6px;">
													<?php
													echo '<button name="save_cell" value="'.$cell['id'].'" style="padding-left:20px; padding-right:10px;  background-image: url(\'../images/system/save.gif\'); border:1px solid #DDDDDD;"  width=200px;" class="buttons">Save Cell</button>';
													?>
												</td>
												<td valign="bottom"  align="right" style="padding-right:6px;">	
													<?php
													if ($j > 0)
													{ echo '<button name="delete_cell" value="'.$cell['id'].'" style="padding-left:20px; padding-right:10px;  background-image: url(\'../images/system/delete.gif\'); border:1px solid #DDDDDD;"  width=200px;" class="buttons">Delete Cell</button>'; }
													?>
												</td>
											</tr>
										</table>
										</form>
										<?php
										echo getBorderHTML(3, 'bot');
										echo '</td>';
										$j++;
									}
									echo '</tr>';
									echo '</table>';
								}
							}
						?>
					</td>
					<td class="admin_cell" valign="top" style="padding-left:10px;">
						<form action="" name="rows_move" method="post">
						<?php
							if($temp_rows)
							{
								foreach($temp_rows as $tr)
								{
									
									echo '<table style="padding-bottom:10px;" height="160" width="100%" cellpadding="0" cellspacing="0" border="0" class="template_row">';
									echo '<tr>';
									echo '<td>';
										echo '<button name="add_cell" value="'.$tr.'" style="padding-left:20px; padding-right:10px;  background-image: url(\'../images/system/new.gif\'); border:1px solid #DDDDDD;"  width=200px;" class="buttons">Add New Cell</button><br /><br />';
										echo '<button name="delete_row" value="'.$tr.'" style="padding-left:20px; padding-right:10px;  background-image: url(\'../images/system/delete.gif\'); border:1px solid #DDDDDD;"  width=200px;" class="buttons"> Delete Row </button>';
									echo '</td>';
									echo '</tr>';
									echo '</table>';
								}
							}
						?>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td></td>
		<td style="padding-top:10px; padding-bottom:10px;">
			
		</td>
		<td></td>
	</tr>
	<?php endif; ?>
</table>